package com.it.Demo1;

import java.util.ArrayList;

public class Student {
    private String name;//姓名
    private int sno ;//学号
    private double score;//成绩

    public Student() {
    }

    public Student(String name, int sno, double score) {
        this.name = name;
        this.sno = sno;
        this.score = score;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSno() {
        return sno;
    }

    public void setSno(int sno) {
        this.sno = sno;
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public static Student[] change(Student[] stu){

        for (int i=0;i<stu.length;i++){
            for (int j = i+1; j < stu.length; j++) {
                if (stu[i].getScore()<stu[j].getScore()){
                    Student temp = stu[i];
                    stu[i]=stu[j];
                    stu[j]=temp;
                }

            }
        }
        for (int i = 0; i <stu.length; i++) {
            System.out.println(stu[i].toString());

        }
        return stu;

    }
    @Override
    public String toString() {
        return "Student{" +
                "姓名='" + name + '\'' +
                ", 学号=" + sno +
                ", 成绩=" + score +
                '}';
    }

    public static void main(String[] args) {
        Student[] stu=new Student[4];
        stu[0]=new Student("zhangsan",1001,56.2);
        stu[1]=new Student("lisi",1002,78.6);
        stu[2]=new Student("wangwu",1003,22.3);
        stu[3]=new Student("maliu",1004,99.9);
        stu=Student.change(stu);
    }
}
